import 'package:flutter/material.dart';
import 'package:labcloud_app/pages/product/home.dart';
import 'package:labcloud_app/pages/search.dart';
import 'package:labcloud_app/pages/message.dart';
import 'package:labcloud_app/pages/uaa/profile.dart';
import 'package:labcloud_app/pages/shopping_cart.dart';

class Index extends StatefulWidget {
  const Index({super.key});

  @override
  State<Index> createState() => _IndexState();
}

class _IndexState extends State<Index> {
  int _currentIndex = 0;

  final List<Widget> _pages = const [
    Home(),
    Search(),
    Message(),
    ShoppingCart(),
    Profile(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: _currentIndex,
        children: _pages,
      ),
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        currentIndex: _currentIndex,
        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
        items: [
          BottomNavigationBarItem(
            activeIcon: Image.asset("assets/icons/home_active.png", width: 24, height: 24),
            icon: Image.asset("assets/icons/home.png", width: 24, height: 24),
            label: '首页',
          ),
          BottomNavigationBarItem(
            activeIcon: Image.asset("assets/icons/search_active.png", width: 24, height: 24),
            icon: Image.asset("assets/icons/search.png", width: 24, height: 24),
            label: '搜索',
          ),
          BottomNavigationBarItem(
            activeIcon: Image.asset("assets/icons/message_active.png", width: 24, height: 24),
            icon: Image.asset("assets/icons/message.png", width: 24, height: 24),
            label: '消息',
          ),
          BottomNavigationBarItem(
            activeIcon: Image.asset("assets/icons/shopping_active.png", width: 24, height: 24),
            icon: Image.asset("assets/icons/shopping.png", width: 24, height: 24),
            label: '购物车',
          ),
          BottomNavigationBarItem(
            activeIcon: Image.asset("assets/icons/mine_active.png", width: 24, height: 24),
            icon: Image.asset("assets/icons/mine.png", width: 24, height: 24),
            label: '我的',
          ),
        ],
      ),
    );
  }
}
